// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import Vuex from 'vuex'
import VueI18n from 'vue-i18n'
import VueQuillEditor from 'vue-quill-editor'
import Element from 'element-ui'
import AMap from 'vue-amap'
import jssha from 'sha.js'
import 'element-ui/lib/theme-default/index.css'

Vue.config.productionTip = false
Vue.use(Vuex)
Vue.use(VueI18n)
Vue.use(VueQuillEditor)
Vue.use(Element)
Vue.use(AMap)

Vue.config.lang = localStorage.getItem('lang')
if (localStorage.getItem('lang') === null) {
  Vue.config.lang = 'zh'
}
const enpackage = require('./assets/en.json')
const zhpackage = require('./assets/zh.json')

const messages = {
  en: enpackage,
  zh: zhpackage
}

const i18n = new VueI18n({
  locale: Vue.config.lang,
  messages,
})

const test_store = new Vuex.Store({
  state: {
    username: '',
    password: '',
    id: '',
    count: 5,
    real_name: '',
    test_stall: [{
      id: '2',
      coordinate_x: 2,
      coordinate_y: 4,
      stalls_name: '二号摊位',
      memo: ''
    }]
  },
  mutations: {
    showUserName (state) {
      alert(state.username)
    },
    showID (state) {
      alert(state.id)
    },
    increment (state) {
      state.count++
    }
  }
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  i18n,
  store: test_store,
  template: '<App/>',
  components: {App}
})
